﻿<shared:UserControlBase x:Class="HP.Cachalote.WPF.UserControls.UnfinishedTodoItemTreeViewUserControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:galaSoft="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WPF4"
             xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
             xmlns:validationRules="clr-namespace:HP.Cachalote.WPF.ValidationRules"
             xmlns:extendedAttachedProperties="clr-namespace:HP.Cachalote.WPF.ExtendedAttachedProperties"   
             xmlns:userControls="clr-namespace:HP.Cachalote.WPF.UserControls"
             xmlns:shared="clr-namespace:HP.Cachalote.WPF.Shared"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300"
             DataContext="{Binding UnfinishedTodoItemTreeView, Source={StaticResource Locator}}">
    <Grid>
        <Grid.RowDefinitions>
            <!-- Label or Filter name -->
            <RowDefinition Height="30" />
            <!-- TodoItem summary info -->
            <RowDefinition Height="20" />
            <!-- DockPanel contains Unfinished TodoItem TreeView and Add New TodoItem Grid -->
            <RowDefinition />
        </Grid.RowDefinitions>
        <!-- Label or Filter name -->
        <TextBlock Grid.Row="0" FontSize="18" Text="{Binding SelectedTypeName}" />
        <!-- TodoItem summary info -->
        <TextBlock Grid.Row="1" Margin="10,0,0,0" Text="{Binding ItemInfoSummary}" Style="{StaticResource ItemInfoSummaryTextBlock}" />
        <DockPanel Grid.Row="2" LastChildFill="True">
            <!-- Add new TodoItem Grid -->
            <Grid DockPanel.Dock="Bottom" Height="30">
                <Grid.Style>
                    <Style TargetType="{x:Type Grid}">
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding CurrentTodoLabel}" Value="{x:Null}">
                                <Setter Property="Visibility" Value="Collapsed" />
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </Grid.Style>
                <Grid.ColumnDefinitions>
                    <!-- Add new TodoItem TextBox -->
                    <ColumnDefinition />
                    <!-- Add & Cancel button -->
                    <ColumnDefinition Width="85" />
                </Grid.ColumnDefinitions>
                <!-- Add new TodoItem TextBox -->
                <Border BorderThickness="1" BorderBrush="DarkGray" Padding="2">
                    <xctk:WatermarkTextBox Style="{StaticResource TodoItemTextBox}" Watermark="Add new Todo, type here ...">
                        <xctk:WatermarkTextBox.WatermarkTemplate>
                            <DataTemplate>
                                <ContentControl Content="{Binding}" FontStyle="Italic" Foreground="DarkGray" FontSize="16" />
                            </DataTemplate>
                        </xctk:WatermarkTextBox.WatermarkTemplate>
                        <xctk:WatermarkTextBox.Text>
                            <Binding Path="NewAddedTodoItemTitle" UpdateSourceTrigger="PropertyChanged" Mode="TwoWay">
                                <Binding.ValidationRules>
                                    <validationRules:TodoItemTitleValidationRule />
                                </Binding.ValidationRules>
                            </Binding>
                        </xctk:WatermarkTextBox.Text>
                    </xctk:WatermarkTextBox>
                </Border>
                <!-- Add button -->
                <Button Grid.Column="1" Margin="4,0,0,0" Width="80" Height="35" IsDefault="True" Content="Add" Command="{Binding AddNewTodoItemCommand}" />
                <!-- Cancel button. Width is 0 because only need to use it to accept ESC button. -->
                <Button Grid.Column="1" Width="0" IsCancel="True" Content="Cancel" Command="{Binding CancelCommand}" />
            </Grid>
            <!-- Unfinished TodoItem TreeView -->
            <TreeView Margin="0" x:Name="TreeViewTodoItems" BorderThickness="0" 
                        ScrollViewer.HorizontalScrollBarVisibility="Disabled" 
                        VerticalAlignment="Top"
                        ItemsSource="{Binding TodoItems}">
                <TreeView.Resources>
                    <SolidColorBrush Color="Transparent" x:Key="{x:Static SystemColors.HighlightBrushKey}" />
                    <SolidColorBrush Color="Black" x:Key="{x:Static SystemColors.HighlightTextBrushKey}" />
                    <SolidColorBrush Color="Transparent" x:Key="{x:Static SystemColors.InactiveSelectionHighlightBrushKey}" />
                </TreeView.Resources>
                <TreeView.ItemTemplate>
                    <DataTemplate>
                        <userControls:UnfinishedTodoItemTreeViewItemUserControl DataContext="{Binding}" />
                    </DataTemplate>
                </TreeView.ItemTemplate>
            </TreeView>
        </DockPanel>            
    </Grid>
</shared:UserControlBase>
